# Maintainer: Simon Zeni <simon@bl4ckb0ne.ca>
pkgname=hare
pkgver=0_git20231127
_commit=d94f355481a320fb2aec13ef62cb3bfe2416f5e4
pkgrel=0
pkgdesc="The Hare systems programming language"
url="https://harelang.org"
arch="x86_64 aarch64 riscv64"
license="MPL-2.0 AND GPL-3.0-only"
depends="qbe harec binutils"
makedepends="scdoc"
checkdepends="tzdata"
subpackages="$pkgname-doc"
source="
	$pkgname-$_commit.tar.gz::https://git.sr.ht/~sircmpwn/hare/archive/$_commit.tar.gz
	config.aarch64.mk
	config.riscv64.mk
	config.x86_64.mk
"
builddir="$srcdir/$pkgname-$_commit"

if [ "$CARCH" = "aarch64" ]; then
	# XXX: Spurious failures on aarch64, often only reproducible in the
	# Alpine build environment
	options="!check"
fi

build() {
	cp "$srcdir"/config.$CARCH.mk ./config.mk
	# Don't use user's global Hare cache
	export XDG_CACHE_HOME="$srcdir"/hare-cache
	mkdir -p "$XDG_CACHE_HOME"
	# Configure build version info
	export VERSION="dev+$(echo "$_commit" | cut -c-7)"
	export LOCALVER=alpine
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
5638e213ac7dedd5a7a0c43bb481755e5cb5d9cbc227a0e08a53bbb4e9036e80111a5a7df2328bd4d1c0ede4cf703dd8a94f075a0850649b31770350223ecb96  hare-d94f355481a320fb2aec13ef62cb3bfe2416f5e4.tar.gz
129189cbc86e1ee0ae5c81a12b2797f36b1a9ed742a81496fff14f8527ef6fe4881a261c2156a5bafcaeaf4a692e3cf8b27c473339676e65479e6f3546a3ee99  config.aarch64.mk
96280a82594b19ec8972946c89fa0f0b9d0e89cc517e6476ace4be8adc66be1d631d75172d36261e9c9414b0e3453be59dd7b4b0abf3735d182c28005dc5eee3  config.riscv64.mk
ad724530acea8377fd9372af416d467470497a4aa80a0405d1d4a9b6ddce609485549ffd31426884fa277b8dcab279288498413fddc41dc23ea24ad30bab224e  config.x86_64.mk
"
